package code20_jdbc.改写学生管理.mapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import code20_jdbc.改写学生管理.entity.Clazz;
import code20_jdbc.改写学生管理.entity.Student;
import code20_jdbc.改写学生管理.util.RowMapper;

public class StudentMapper implements RowMapper<Student>{

	@Override
	public Student mapRow(ResultSet rs) throws SQLException {
		Student s = new Student();
		s.setId(rs.getInt("id"));
		s.setName(rs.getString("name"));
		s.setAge(rs.getInt("age"));
		s.setHeight(rs.getDouble("height"));
		s.setBirthday(rs.getDate("birthday"));
		
		Clazz c = new Clazz();
		c.setCid(rs.getInt("cid"));
		c.setCname(rs.getString("cname"));
		c.setRoom(rs.getString("room"));
		s.setClazz(c);
		return s;
	}

}
